package java4;

import java.util.Arrays;
import java.util.Scanner;

public class Q1 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int width, length, radius;
		Shape[] shapes = new Shape[n];
		for (int i = 0; i < n; i++) {
			String key = in.next();
			if (key.equals("rect")) {
				width = in.nextInt();
				length = in.nextInt();
				shapes[i] = new Rectangle(width, length);
			}
			if (key.equals("cir")) {
				radius = in.nextInt();
				shapes[i] = new Circle(radius);
			}
		}
		System.out.println(sumAllPerimeter(shapes));
		System.out.println(sumAllArea(shapes));
		System.out.println(Arrays.toString(shapes));
		for (int k=0;k<n;k++) {
			System.out.printf(shapes[k].getClass() + ",");
			System.out.println(shapes[k].getClass().getSuperclass());
		}
		
	}

public static double sumAllPerimeter(Shape[] shapes){
	double sumAllPerimeter=0;
	for(Shape sum1:shapes){
		sumAllPerimeter += sum1.getPerimeter();
	}
	return sumAllPerimeter;
}
public static double sumAllArea(Shape[] shapes){
	double sumAllArea=0;
	for(Shape sum2:shapes){
		sumAllArea += sum2.getArea();
	}
	return sumAllArea;
}
}

abstract class Shape {
	final double PI = 3.14;

	public abstract double getPerimeter();

	public abstract double getArea();

}

class Rectangle extends Shape {
	private int width;
	private int length;

	public Rectangle(int width, int length) {
		this.width = width;
		this.length = length;
	}

	public double getPerimeter() {
		return (width + length) * 2;
	}

	public double getArea() {
		return width * length;
	}

	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

}

class Circle extends Shape {
	
	private int radius;

	public Circle(int radius) {
		this.radius = radius;
	}
	public double getPerimeter() {
		return 2*PI*radius;
	}
	public double getArea() {
		return PI*radius*radius;
	}
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}

	public int getRadius() {
		return radius;
	}

	public void setRadius(int radius) {
		this.radius = radius;
	}
}
